// var host ='http://ccpp.denong.com/app_person/';
// var host = "https://mini.xqx.com/app_person/";
var Default = require("../../Tools/Default.js");
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    class:{
      type: String,
      value: 'bargin_share_btn',
    },
    innerText: {
      type: String,
      value: '喊朋友砍一刀',
    },
    img_url: {
      type: String,
      value: '',
    },
    name:{
      type: String,
      value: '哈哈哈',
    },
    group_price:{
      type: String,
      value: '0.01',
    },
    price:{
      type: String,
      value: '100',
    },
    currency:{
      type: String,
      value: '0.01',
    },
    page:{
      type: String,
      value: '',
    },
    intPara:{
      type: String,
      value: '',
    },
    intParatwo:{
      type: String,
      value: '',
    },
    leibie:{
      type: String,
      value: '',
    },
    cnd:{
      type: String,
      value: '',
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    hid:false,  
  },
  /**
   * 组件的方法列表
   */
  methods: {
    // 点击取消按钮
    cancelBtn: function () {
      this.setData({
        hid: false
      })
    },
    aa:function(){
      this.setData({
        hid: false
      })
    },
    // 点击分享朋友圈按钮
    shareImg: function (e) {
      wx.showLoading({
        title: '加载中',
        mask: true
      })
      console.log(e)
      // console.log(e.currentTarget.dataset)
      var imgurl = e.currentTarget.dataset.imgurl;
      var nowrmb = e.currentTarget.dataset.nowrmb;
      var prermb = e.currentTarget.dataset.prermb;
      var title = e.currentTarget.dataset.title;
      var xj = e.currentTarget.dataset.xj;
      var leibie = e.currentTarget.dataset.leibie;

      var page1 = e.currentTarget.dataset.page;
      var token = wx.getStorageSync("token");
      console.log(token)
      var intPara = e.currentTarget.dataset.intpara;
      var intPara2 = e.currentTarget.dataset.intparatwo;
      var cnd = e.currentTarget.dataset.cnd;
      var obj=null;
      if (leibie =='kanjia'){
            console.log('我是砍价')
            obj = {
              page: page1,
              token: token,
              intPara: intPara,
              intPara2: intPara2
            }
      } else if (leibie == 'pintuan'){
          console.log('我是拼团')
          obj = {
            page: page1,
            token: token,
            cnd:cnd
          }
      }
      wx.request({
        url: Default.HOST + 'xcxgroupbuy/createCode',
        method: "POST",
        data: obj,
        header: {
          'content-type': 'application/json' // 默认值
        },
        success: function (res) {
          console.log(res)
          var shareImgSrc = res.data.data;
          wx.setStorageSync('shareImgSrc', shareImgSrc);
          wx.hideLoading()
          console.warn(wx.getStorageSync('shareImgSrc'))
          wx.navigateTo({
            url: '../shareFriends/shareFriends?imgurl=' + imgurl + '&nowrmb=' + nowrmb + '&prermb=' + prermb + '&title=' + title + '&xj=' + xj,
          })
        }
      })

      this.setData({
        hid: false
      })
    },
    // 点击分享按钮
    listenerButton: function () {
      this.setData({
        hid: true
      })
    },
    

  }
})
